# 加载django的环境
import os
import django

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'NavelApi.settings.dev')
django.setup()

# 三步走，加载django的环境，执行定时任务，任务的定时配置，
from celery import Celery

broker = 'redis://127.0.0.1:6379/3'
banckend = 'redis://127.0.0.1:6379/4'

app = Celery(__name__, broker=broker, banckend=banckend,
             include=['celery_task.sms_task', 'celery_task.home_task.banner_task'])

# 任务的定时配置
from datetime import timedelta
from celery.schedules import crontab

app.conf.timezone = 'Asia/Shanghai'
app.conf.enable_utc = False
app.conf.beat_schedule = {
    'task1': {
        'task': 'celery_task.home_task.banner_task.update_banner',
        'schedule': timedelta(days=1),
    },
}
